import { Message } from "element-ui";

export const sendMessageToContent = async (to, params) => {
  const tabs = await chrome.tabs.query({ active: true });
  console.log("active tabs", tabs);
  const [tab] = tabs;
  if (!tab.id) return;
  try {
    return await chrome.tabs.sendMessage(tab.id, { action: to, data: params });
  } catch (ex) {
    Message.error({
      customClass: 'el-message-index',
      message:"页面无法使用此功能"});
    throw ex;
  }
};
